import { Storage } from "./bcat/storage/Storage"
import { assert } from "./bcat/util/assert"
import {VariableStorage} from "./variable-storage"

App({
  test() {
    console.log("test equal sign...");
    assert(undefined !== true);
    assert(undefined != false);


    console.log("test VariableStorage...");
    const KEY = "kIS_TERM_AGREE";

    let st = Storage.default();
    st.delete(KEY);
    assert(false == st.has(KEY));


    let vst = VariableStorage.from(KEY, st);
    assert(vst.isSynced());
    assert(undefined == vst.get());

    assert(vst.set(false));
    assert(false == vst.get());
    assert(false == vst.isSynced());

    assert(true == vst.save());
    assert(vst.isSynced());

    assert(vst.set(true));
    assert(false == vst.isSynced());
    assert(true == vst.get());
    assert(false == vst.load());
    assert(vst.isSynced());

    vst.delete();
    assert(vst.isSynced());

    st = null;

  },
  onLaunch(options) {
    // 第一次打开
    // options.query == {number:1}
    console.info('App onLaunch');
    this.test();
  },
  onShow(options) {
    // 从后台被 scheme 重新打开
    // options.query == {number:1}
  },
});

